<meta charset="utf-8">
<div data-page="post-list" class="page navbar-through no-toolbar">
	<div class="navbar">
		<div class="navbar-inner">
			<div class="left">
				<a href="#" class="link back icon-only"><i
					class="ti-arrow-circle-left"></i></a>
			</div>
			<div class="center">同事圈</div>
			<div class="right">
				<a href="<%=sails.config.application.appPrefix%>/post/get?method=create"
					class="link icon-only"><i class="ti-plus"></i></a>
			</div>
		</div>
	</div>

	<div class="page-content">
		<div class="list-block media-list post-list">
			<ul>
				<% posts.forEach(function(post){ %>
				<li class="item-content">
					<div class="item-inner">
						<div class="item-title-row">
							<div class="item-title">
								<img width="24" src="<%=post.owner.avatar %>64">
								<span><%=post.owner.name %></span>
							</div>
							<div class="item-after">
								<%= sails.formatTime(post.updatedAt)%>
								&nbsp;
								<% if (req.session.user.userid == post.owner.userid) { %>
								<a href="#" class="sails-btn-delete" api-path="/api/post" message="真的要删除吗？" pkid="<%=post.id %>">删除</a>
								<% } %>
							</div>
						</div>
						<div class="item-text"><%=post.content %></div>
						
						<% if (post.attachments.length != 0) { %>
						<div class="item-text">
						<div class="row wx-gallery-view">
							<% post.attachments.forEach(function(file){ %>
							<div class="col-33"><a href="#"><img data-src="<%=sails.config.application.baseUrl%>/files?filename=<%=file.filename%>" class="lazy lazy-fadein"></a></div>
							<% }) %>
							<% for(var i=0;i< 3-post.attachments.length;i++){ %>
							<div class="col-33"></div>
							<% } %>
						</div>
						</div>
						<% } %>
						
						<div class="item-text">
							<a href="#" class="btn-add-likes" post-id="<%=post.id %>">
								<i class="ti-heart"></i>
								<span><%=post.likes %></span>
							</a>
							<a href="#" class="btn-comment-create" post-id="<%=post.id %>">
								<i class="ti-comment-alt"></i>
								<span><%=post.comments.length %></span>
							</a>
						</div>
						
						<% if (post.comments.length != 0) { %>
						<div class="item-text comments">
						<ul>
							<% post.comments.forEach(function(comment){ %>
							<li>
								<span><%=comment.owner.name %> : </span><%=comment.content %>
								<% if (req.session.user.userid == comment.owner.userid) { %>
								<a href="#" class="sails-btn-delete" api-path="/api/comment" message="真的要删除吗？" pkid="<%=comment.id %>">删除</a>
								<% } %>
							</li>
							<% }) %>
						</ul>
						</div>
						<% } %>
					</div>
				</li>
				<% }) %>
			</ul>
		</div>
	</div>

</div>